﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace _百度数据表格
{
    /// <summary>
    /// DownloadHandler 的摘要说明
    /// </summary>
    public class DownloadHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //获取文件名称
            string FileName = context.Request.QueryString["filename"] ?? "";
            //获取文件路径
            string Paths = "~/DownLoad/";

            string FileExt = Path.GetExtension(FileName);

            //设置为附件模式
            context.Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlDecode(FileName));

            context.Response.WriteFile(Paths + FileName);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}